<?php 
	session_start(); 
	// echo "输出sessionid = " . session_id() . "<br>";

	class MemberSessionInfo {
		static function setLoginInfo($key, $value) {
			$_SESSION[$key] = $value;
			// echo "存入成功" . "<br>";
			// echo "$key = " . $_SESSION[$key];
		}

		static function getLoginInfo($key) {
			@$value = $_SESSION[$key];
			// echo "输出$key = " . $value . "<br>";
			
			return $value;
		}

		// 检查
		static function checkMemberLogin(){
			@$mobile = MemberSessionInfo::getLoginInfo("MemberMobile");
			@$password = MemberSessionInfo::getLoginInfo("MemberPassword");
			@$avatar = MemberSessionInfo::getLoginInfo("MemberAvatar");
			@$username = MemberSessionInfo::getLoginInfo("MemberUsername");
			@$nickname = MemberSessionInfo::getLoginInfo("MemberNickname");
			@$gender = MemberSessionInfo::getLoginInfo("MemberGender");
			// 未登录，直接先跳登录页面
			if ($mobile == "") {
				return NULL;
			}
			return $arrayName = array('mobile' => $mobile, 
									   'password' => $password,
									   'username' => $username,
									   'nickname' => $nickname,
									   'gender' => $gender,
									   'avatar' => $avatar);
		}

		static function outMemberLogin() {
			MemberSessionInfo::setLoginInfo("MemberMobile", NULL);
			MemberSessionInfo::setLoginInfo("MemberPassword", NULL);
			MemberSessionInfo::setLoginInfo("MemberAvatar", NULL);
			header("Location:index.php", true);
		}
	}

	 
 	
?>
